#Boa:MDIParent:MDIParentFrame1

import wx
import numpy
from MDIChildFrame1 import MDIChildFrame1
from VarsPanel import VarsPanel

def create(parent):
    return MDIParentFrame1(parent)

[wxID_MDIPARENTFRAME1, wxID_MDIPARENTFRAME1PANEL1, 
 wxID_MDIPARENTFRAME1SASHLAYOUTWINDOW1, wxID_MDIPARENTFRAME1STATUSBAR1, 
] = [wx.NewId() for _init_ctrls in range(4)]

[wxID_MDIPARENTFRAME1MENU1FILE_NEW, wxID_MDIPARENTFRAME1MENU1ITEMS2, 
] = [wx.NewId() for _init_coll_menu1_Items in range(2)]

class MDIParentFrame1(wx.MDIParentFrame):
    _custom_classes = {'wx.Panel': ['VarsPanel', 'VarsPanel']}

    def _init_coll_menuBar1_Menus(self, parent):
        # generated method, don't edit

        parent.Append(menu=self.menu1, title=u'&File')

    def _init_coll_menu1_Items(self, parent):
        # generated method, don't edit

        parent.Append(help='', id=wxID_MDIPARENTFRAME1MENU1FILE_NEW,
              kind=wx.ITEM_NORMAL, text=u'&New')
        parent.AppendSeparator()
        parent.Append(help='', id=wxID_MDIPARENTFRAME1MENU1ITEMS2,
              kind=wx.ITEM_NORMAL, text=u'&Exit')
        self.Bind(wx.EVT_MENU, self.OnFileNew,
              id=wxID_MDIPARENTFRAME1MENU1FILE_NEW)
        self.Bind(wx.EVT_MENU, self.OnFileExit,
              id=wxID_MDIPARENTFRAME1MENU1ITEMS2)

    def _init_utils(self):
        # generated method, don't edit
        self.menuBar1 = wx.MenuBar()

        self.menu1 = wx.Menu(title='')

        self._init_coll_menuBar1_Menus(self.menuBar1)
        self._init_coll_menu1_Items(self.menu1)

    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.MDIParentFrame.__init__(self, id=wxID_MDIPARENTFRAME1, name='',
              parent=prnt, pos=wx.Point(355, 241), size=wx.Size(662, 532),
              style=wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL,
              title=u'PyMatLab')
        self._init_utils()
        self.SetClientSize(wx.Size(654, 505))
        self.SetMenuBar(self.menuBar1)
        self.Center(wx.BOTH)
        self.SetThemeEnabled(True)
        self.Bind(wx.EVT_CLOSE, self.OnMDIParentFrame1Close)
        self.Bind(wx.EVT_SIZE, self.OnMDIParentFrame1Size)

        self.statusBar1 = wx.StatusBar(id=wxID_MDIPARENTFRAME1STATUSBAR1,
              name='statusBar1', parent=self, style=wx.ST_SIZEGRIP)
        self.SetStatusBar(self.statusBar1)

        self.sashLayoutWindow1 = wx.SashLayoutWindow(id=wxID_MDIPARENTFRAME1SASHLAYOUTWINDOW1,
              name='sashLayoutWindow1', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(654, 466), style=wx.CLIP_CHILDREN | wx.SW_3D)
        self.sashLayoutWindow1.SetAlignment(wx.LAYOUT_LEFT)
        self.sashLayoutWindow1.SetOrientation(wx.LAYOUT_VERTICAL)
        self.sashLayoutWindow1.SetSashVisible(wx.SASH_RIGHT, True)
        self.sashLayoutWindow1.SetDefaultSize(wx.Size(200, 1000))
        self.sashLayoutWindow1.Bind(wx.EVT_SASH_DRAGGED,
              self.OnSashLayoutWindow1SashDragged,
              id=wxID_MDIPARENTFRAME1SASHLAYOUTWINDOW1)

        self.panel1 = VarsPanel(id=wxID_MDIPARENTFRAME1PANEL1, name='panel1',
              parent=self.sashLayoutWindow1, pos=wx.Point(0, 0),
              size=wx.Size(651, 466), style=wx.TAB_TRAVERSAL)

    def __init__(self, parent):
        self._init_ctrls(parent)
        self.count = 0

    def get_arraylist(self):
        #numpy.who()
        return [(k, v) for k, v in vars().items() if isinstance(v, numpy.ndarray)]

    def OnFileNew(self, event):
        f = MDIChildFrame1(self)
        f.Show(True)
        self.panel1.regArray('a'+str(self.count), f.getArray())
        self.count += 1

    def OnMDIParentFrame1Close(self, event):
        self.Destroy()

    def OnFileExit(self, event):
        self.Close()

    def OnSashLayoutWindow1SashDragged(self, event):
        if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
            return

        self.sashLayoutWindow1.SetDefaultSize((event.GetDragRect().width, 1000))

        wx.LayoutAlgorithm().LayoutMDIFrame(self)
        self.GetClientWindow().Refresh()

    def OnMDIParentFrame1Size(self, event):
        wx.LayoutAlgorithm().LayoutMDIFrame(self)
